package com.puman.watchtrade.fragment.home.adapter;

import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;

import com.puman.watchtrade.R;
import com.puman.watchtrade.fragment.home.imageLoader.util.CheckImageLoaderConfiguration;
import com.puman.watchtrade.fragment.sell.util.UniversalImageLoadTool;
import com.puman.watchtrade.util.GlobalData;
import com.puman.watchtrade.util.ImageDownloader;

public class GoodsShowImageListViewAdapter extends BaseAdapter {

	private LayoutInflater listContainer; // ��ͼ����
	private View view;
	private Activity activity;
	private ImageDownloader mDownloader;
	List<String> showImgList;
//	private String topTitleStr = "";

	public final class ListItemView {
		public ImageView image;
	}

	public GoodsShowImageListViewAdapter(Activity activity,
			List<String> showImgList) {
		this.activity = activity;
		this.showImgList = showImgList;
//		this.topTitleStr = topTitleStr;
		listContainer = LayoutInflater.from(activity);
	}

	/**
	 */
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final ListItemView listItemView;
		final int selectID = position;
		if (convertView == null) {
			listItemView = new ListItemView();
			convertView = listContainer
					.inflate(R.layout.goods_image_item, null);
			listItemView.image = (ImageView) convertView
					.findViewById(R.id.info_item_image);
			convertView.setTag(listItemView);
		} else {
			listItemView = (ListItemView) convertView.getTag();
		}
		
		int height = (int) (GlobalData.screenWidth *((float)400/(float)640));
		LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,height);
		listItemView.image.setLayoutParams(layoutParams);

		if (!showImgList.get(position).equals("")) {
			CheckImageLoaderConfiguration
					.checkImageLoaderConfiguration(activity);
//			if (topTitleStr.equals("钟表")) {
				UniversalImageLoadTool.display(showImgList.get(position),
						(ImageView) listItemView.image, R.drawable.load_default);
//			} else if (topTitleStr.equals("首饰")) {
//				UniversalImageLoadTool.display(showImgList.get(position),
//						(ImageView) listItemView.image, R.drawable.load_default);
//			} else if (topTitleStr.equals("包袋")) {
//				UniversalImageLoadTool.display(showImgList.get(position),
//						(ImageView) listItemView.image, R.drawable.load_default);
//			} else if (topTitleStr.equals("其他")) {
//				UniversalImageLoadTool.display(showImgList.get(position),
//						(ImageView) listItemView.image, R.drawable.load_default);
//			}
//			UniversalImageLoadTool.display(showImgList.get(position),
//					(ImageView) listItemView.image, R.drawable.home_item1);
		}

		return convertView;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return showImgList.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub

		return 0;
	}

}